//
//  Good_detial_Table_Cell.m
//  Food
//
//  Created by dllo on 15/7/18.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "Good_detial_Table_Cell.h"
#import "UIImageView+WebCache.h"
#import "BaseHeader.h"
@implementation Good_detial_Table_Cell

-(void)dealloc
{
    [_aView release];
    [_materialNameLable release];
    [_aImageview release];
    [_contentDescriptionLable release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.aView = [[UIView alloc] init];
        [self.contentView addSubview:self.aView];
        
        self.aImageview = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.aView addSubview:self.aImageview];
        
        self.materialNameLable = [[UILabel alloc] init];
        self.materialNameLable.backgroundColor = [UIColor whiteColor];
        self.materialNameLable.numberOfLines = 0;
        [self.aView addSubview:self.materialNameLable];
        
        self.contentDescriptionLable = [[UILabel alloc] init];
        self.contentDescriptionLable.backgroundColor = [UIColor colorWithRed:0.93 green:0.89 blue:0.81 alpha:1];
        [self.contentView addSubview:self.contentDescriptionLable];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.aView.frame = CGRectMake(20, 10, (ScreenWidth - 40) / 2.0 - 30, 50);
    
    self.aImageview.frame = CGRectMake(0, 0, self.aView.frame.size.width / 2.0, 50);
    
    self.materialNameLable.frame = CGRectMake(self.aImageview.frame.size.width, 0, self.aImageview.frame.size.width, 50);
    
    self.contentDescriptionLable.frame = CGRectMake(self.aView.frame.origin.x + self.aView.frame.size.width, 10, self.aView.frame.size.width + 60, 50);
}

- (void)setModel:(Good_Bad_Model *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
        
    }
    [self.aImageview sd_setImageWithURL: [NSURL URLWithString:model.imageName]placeholderImage:nil
     ];
    
    self.materialNameLable.text = model.materialName;
    NSString *str = [NSString stringWithFormat:@"   %@", model.contentDescription];
    self.contentDescriptionLable.text = str;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
